package com.htc.android.footprints.activity;

import android.app.Activity;
import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import com.htc.android.footprints.utils.ImeLauncher;

public class EditLocationActivity extends Activity
{
  private static final String TAG = "EditLocationActivity";
  private Button mButtonCancel;
  private Button mButtonDone;
  private Button mButtonLat;
  private Button mButtonLon;
  private EditText mEditDegLat;
  private EditText mEditDegLon;
  private EditText mEditMinLat;
  private EditText mEditMinLon;
  private EditText mEditSecLatDec;
  private EditText mEditSecLatInt;
  private EditText mEditSecLonDec;
  private EditText mEditSecLonInt;
  private EditText[] mEditTexts;
  private int mLat;
  private int mLon;
  private String mTextE;
  private String mTextN;
  private String mTextS;
  private String mTextW;
  private View.OnClickListener onCancelClickListener = new View.OnClickListener()
  {
    public void onClick(View paramView)
    {
      EditLocationActivity.this.setResult(0);
      EditLocationActivity.this.finish();
    }
  };
  private View.OnClickListener onDoneClickListener = new View.OnClickListener()
  {
    public void onClick(View paramView)
    {
      EditLocationActivity.this.checkEmpty();
      double[] arrayOfDouble = EditLocationActivity.this.getData();
      Intent localIntent = new Intent();
      localIntent.putExtra("RETURN_LATITUDE", arrayOfDouble[0]);
      localIntent.putExtra("RETURN_LONGITUDE", arrayOfDouble[1]);
      EditLocationActivity.this.setResult(-1, localIntent);
      EditLocationActivity.this.finish();
    }
  };
  private View.OnClickListener onNewsClickListener = new View.OnClickListener()
  {
    public void onClick(View paramView)
    {
      Button localButton = (Button)paramView;
      String str = localButton.getText().toString();
      if (str.equals(EditLocationActivity.this.mTextN))
        localButton.setText(EditLocationActivity.this.mTextS);
      while (true)
      {
        return;
        if (str.equals(EditLocationActivity.this.mTextE))
        {
          localButton.setText(EditLocationActivity.this.mTextW);
          continue;
        }
        if (str.equals(EditLocationActivity.this.mTextW))
        {
          localButton.setText(EditLocationActivity.this.mTextE);
          continue;
        }
        localButton.setText(EditLocationActivity.this.mTextN);
      }
    }
  };

  private void checkEmpty()
  {
    EditText[] arrayOfEditText = this.mEditTexts;
    int i = arrayOfEditText.length;
    for (int j = 0; j < i; j++)
    {
      if (arrayOfEditText[j].getText().length() != 0)
        continue;
      arrayOfEditText[j].setText("0");
    }
  }

  private double[] getData()
  {
    int i = Integer.parseInt(this.mEditDegLat.getText().toString());
    int j = Integer.parseInt(this.mEditMinLat.getText().toString());
    int k = Integer.parseInt(this.mEditSecLatInt.getText().toString());
    int m = Integer.parseInt(this.mEditSecLatDec.getText().toString());
    if (i > 89)
      i = 89;
    if (j > 59)
      j = 59;
    if (k > 59)
    {
      k = 59;
      m = 0;
    }
    while (true)
    {
      int n = Integer.parseInt(this.mEditDegLon.getText().toString());
      int i1 = Integer.parseInt(this.mEditMinLon.getText().toString());
      int i2 = Integer.parseInt(this.mEditSecLonInt.getText().toString());
      int i3 = Integer.parseInt(this.mEditSecLonDec.getText().toString());
      if (n > 179)
        n = 179;
      if (i1 > 59)
        i1 = 59;
      label185: String str1;
      String str2;
      if (i2 > 59)
      {
        i2 = 59;
        i3 = 0;
        str1 = i + ":" + j + ":" + k + "." + m;
        str2 = n + ":" + i1 + ":" + i2 + "." + i3;
      }
      try
      {
        double d1 = Location.convert(str1);
        double d2 = Location.convert(str2);
        double d3 = d2;
        if (this.mButtonLat.getText().toString().equals(this.mTextS))
          d1 *= -1.0D;
        if (this.mButtonLon.getText().toString().equals(this.mTextW))
          d3 *= -1.0D;
        arrayOfDouble = new double[2];
        arrayOfDouble[0] = d1;
        arrayOfDouble[1] = d3;
        return arrayOfDouble;
        if ((k != 59) || (m == 0))
          continue;
        m = 0;
        continue;
        if ((i2 != 59) || (i3 == 0))
          break label185;
        i3 = 0;
      }
      catch (IllegalArgumentException localIllegalArgumentException)
      {
        while (true)
        {
          Log.e("EditLocationActivity", "Location.convert fail");
          Log.e("EditLocationActivity", localIllegalArgumentException.getMessage());
          double[] arrayOfDouble = null;
        }
      }
    }
  }

  private void init()
  {
    this.mTextN = getString(2131361803);
    this.mTextE = getString(2131361804);
    this.mTextW = getString(2131361806);
    this.mTextS = getString(2131361805);
    this.mEditDegLat = ((EditText)findViewById(2131492940));
    this.mEditMinLat = ((EditText)findViewById(2131492941));
    this.mEditSecLatInt = ((EditText)findViewById(2131492942));
    this.mEditSecLatDec = ((EditText)findViewById(2131492943));
    this.mEditDegLon = ((EditText)findViewById(2131492945));
    this.mEditMinLon = ((EditText)findViewById(2131492946));
    this.mEditSecLonInt = ((EditText)findViewById(2131492947));
    this.mEditSecLonDec = ((EditText)findViewById(2131492948));
    EditText[] arrayOfEditText = new EditText[8];
    arrayOfEditText[0] = this.mEditDegLat;
    arrayOfEditText[1] = this.mEditMinLat;
    arrayOfEditText[2] = this.mEditSecLatInt;
    arrayOfEditText[3] = this.mEditSecLatDec;
    arrayOfEditText[4] = this.mEditDegLon;
    arrayOfEditText[5] = this.mEditMinLon;
    arrayOfEditText[6] = this.mEditSecLonInt;
    arrayOfEditText[7] = this.mEditSecLonDec;
    this.mEditTexts = arrayOfEditText;
    this.mButtonLat = ((Button)findViewById(2131492944));
    this.mButtonLon = ((Button)findViewById(2131492949));
    this.mButtonLat.setOnClickListener(this.onNewsClickListener);
    this.mButtonLon.setOnClickListener(this.onNewsClickListener);
    this.mButtonDone = ((Button)findViewById(2131492896));
    this.mButtonCancel = ((Button)findViewById(2131492897));
    this.mButtonDone.setOnClickListener(this.onDoneClickListener);
    this.mButtonCancel.setOnClickListener(this.onCancelClickListener);
    Intent localIntent = getIntent();
    this.mLat = localIntent.getIntExtra("LATITUDE", 0);
    this.mLon = localIntent.getIntExtra("LONGITUDE", 0);
    setData();
    this.mEditDegLat.requestFocus();
  }

  private void setData()
  {
    double d1 = this.mLat / 1000000.0D;
    double d2 = this.mLon / 1000000.0D;
    if (d1 < 0.0D)
    {
      d1 *= -1.0D;
      this.mButtonLat.setText(this.mTextS);
    }
    if (d2 < 0.0D)
    {
      d2 *= -1.0D;
      this.mButtonLon.setText(this.mTextW);
    }
    String str1 = Location.convert(d1, 2);
    String str2 = Location.convert(d2, 2);
    String[] arrayOfString1 = str1.split(":");
    this.mEditDegLat.setText(arrayOfString1[0]);
    this.mEditMinLat.setText(arrayOfString1[1]);
    String[] arrayOfString2 = arrayOfString1[2].split("\\.");
    this.mEditSecLatInt.setText(arrayOfString2[0]);
    String[] arrayOfString4;
    if (arrayOfString2.length >= 2)
    {
      if (arrayOfString2[1].length() > 2)
      {
        String str4 = arrayOfString2[1].substring(0, 2);
        this.mEditSecLatDec.setText(str4);
      }
    }
    else
    {
      String[] arrayOfString3 = str2.split(":");
      this.mEditDegLon.setText(arrayOfString3[0]);
      this.mEditMinLon.setText(arrayOfString3[1]);
      arrayOfString4 = arrayOfString3[2].split("\\.");
      this.mEditSecLonInt.setText(arrayOfString4[0]);
      if (arrayOfString4.length >= 2)
      {
        if (arrayOfString4[1].length() <= 2)
          break label281;
        String str3 = arrayOfString4[1].substring(0, 2);
        this.mEditSecLonDec.setText(str3);
      }
    }
    while (true)
    {
      return;
      this.mEditSecLatDec.setText(arrayOfString2[1]);
      break;
      label281: this.mEditSecLonDec.setText(arrayOfString4[1]);
    }
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    requestWindowFeature(1);
    setContentView(2130903051);
    init();
  }

  public void onDestroy()
  {
    this.mEditTexts = null;
    super.onDestroy();
  }

  public void onResume()
  {
    super.onResume();
    EditText[] arrayOfEditText = this.mEditTexts;
    int i = arrayOfEditText.length;
    for (int j = 0; ; j++)
    {
      if (j < i)
      {
        if (!arrayOfEditText[j].isFocused())
          continue;
        ImeLauncher.getInstance(this).show(arrayOfEditText[j]);
      }
      return;
    }
  }
}

/* Location:           E:\workspace\dex2java\dex-translator-0.0.9.3\HtcFootprints_dex2jar.jar
 * Qualified Name:     com.htc.android.footprints.activity.EditLocationActivity
 * JD-Core Version:    0.6.0
 */